//
//  CurrentTimeViewController.m
//  HypnoTime
//
//  Created by Xia Yong on 13-1-10.
//  Copyright (c) 2013年 Xia Yong. All rights reserved.
//

#import "CurrentTimeViewController.h"

@interface CurrentTimeViewController ()

// 当UIViewController对象的视图即将加入窗口时调用
- (void)viewWillAppear:(BOOL)animated;

// 当UIViewController对象的视图即将消失、被覆盖或是隐藏时调用
- (void)viewWillDisappear:(BOOL)animated;

@end

@implementation CurrentTimeViewController

@synthesize timeLabel = _timeLabel;

- (IBAction)showTime:(UIButton *)sender {
    NSDate *now = [NSDate date];
    static NSDateFormatter *formater = nil;
    if (!formater) {
        formater = [[NSDateFormatter alloc] init];
        [formater setTimeStyle:NSDateFormatterMediumStyle];
    }
    
    self.timeLabel.text = [formater stringFromDate:now];
}

- (void)viewWillAppear:(BOOL)animated {
    NSLog(@"%@ will appear", self.class);
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    NSLog(@"%@ will disappear", self.class);
    [super viewDidAppear:animated];
    self.timeLabel.text = @"???";
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	
    [self.view setBackgroundColor:[UIColor grayColor]];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
